package util;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
/**
 * 返回数据包装类
 * code 响应码
 * msg 响应提示信息
 * data 响应内容
 */
public class R {
    public static final Integer CODE_SUCCESS = 200;
    public static final Integer CODE_ERR = 400;
    public static final Integer CODE_SYS_ERR = 500;
    public static final Integer CODE_NOT_FIND = 401;
    public static final Integer CODE_EXIST = 600;
    public static final String MSG_SUCCESS = "操作成功";
    public static final String MSG_ERR = "操作失败";
    public static final String MSG_NOT_FIND = "资源未找到";
    public static final String MSG_EXIST = "数据已存在";
    public static final String MSG_SYS_ERR = "服务器错误";

    private Integer code;
    private String msg;
    private Object data;
    private Number total;

    public R(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }
    public R(Integer code, Object data,Number total) {
        this.code = code;
        this.data = data;
        this.total = total;
    }
    public R(Integer code, Object data,Number total,String msg) {
        this.code = code;
        this.data = data;
        this.total = total;
        this.msg = msg;
    }
    public R(Integer code,Object data, String msg) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
    public static R data(Integer code, Object data){
        return new R(code,data);
    }
    public static R data(Integer code,Object data, String msg){
        return new R(code,data,msg);
    }
    public static R data(Integer code,Object data, Number total){
        return new R(code,data,total);
    }
    public static R data(Integer code,Object data, Number total,String msg){
        return new R(code,data,total,msg);
    }

}
